/*
 * Copyright 2008-2015 GuanAiHui inc. 
 */
package com.pretty.adminapp.pojo.model.um;

import com.pretty.adminapp.pojo.base.AutoIdBaseEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Set;

/**
 * Role:
 *
 * @author Dennis Ge
 */
@Entity
@Table(name = "um_role")
@DynamicInsert
@DynamicUpdate
public class Role extends AutoIdBaseEntity {

	@Column(name = "code")
	private String code;

	@Column(name = "name")
	private String name;

	@Column(name = "remark")
	private String remark;

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "um_role_permission", joinColumns = { @JoinColumn(name = "role_id") }, inverseJoinColumns = {
			@JoinColumn(name = "permission_id") })
	private Set<Permission> permissions;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(Set<Permission> permissions) {
		this.permissions = permissions;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Override
	public String toString() {
		return "Role [code=" + code + ", name=" + name + ", remark=" + remark + ", permissions=" + permissions + "]";
	}

}
